#include "../NewSyndrome-module.h"
#include "admin-public.h"

void
module_init (void)
{
  bot_set_auteur_module ("Thaeron");
  bot_set_desc_module ("Pour faire parler le bot");
  bot_set_ident_module ("say");
  bot_set_version_module ("0.1");
  bot_add_cmd_handler ("say", "say_it");
  bot_add_cmd_handler ("do", "do_it");
}

void
init_dep (char *nom, void *addr)
{
  static byte mut = 0;
  if (!mut++)
    admin_is_admin = NULL;

  if (!strcmp (nom, "admin_is_admin"))
    admin_is_admin = (void *) addr;

#ifdef WIN32
  init_share_dep (nom, addr);
#endif
}


int
say_it (msg * i)
{
  char *buck;
  if ((!is_botnick (i->dest)) || (i->nbarg < 3)
      || (admin_is_admin (i->sender) < 3000))
    return 0;

  buck = argu_to_string (i->argu, i->nbarg, "", 2);
  bot_send_privmsg (i->argu[1], buck);
  free (buck);
  return 0;
}

int
do_it (msg * i)
{
  char *buck;
  if ((!is_botnick (i->dest)) || (i->nbarg < 3)
      || (admin_is_admin (i->sender) < 3000))
    return 0;

  buck = argu_to_string (i->argu, i->nbarg, "ACTION ", 2);
  strcat (buck, "");
  bot_send_privmsg (i->argu[1], buck);
  free (buck);
  return 0;
}
